package de.tc.stammdatenverwaltung.mailing;


import com.hexidec.ekit.EkitCore;
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.JFrame;


public class EkitWrapper extends JFrame{

  private EkitCore ec = null;

  public EkitWrapper(String content)
  {
    ec = new EkitCore(false);
    ec.setFrame(this);
    ec.setDocumentText(content);
    
    boolean includeToolBar = true;
    boolean multiBar = true;
    
    /* Add the components to the app */
		if(includeToolBar)
		{
			if(multiBar)
			{
				this.getContentPane().setLayout(new GridBagLayout());
				GridBagConstraints gbc = new GridBagConstraints();
				gbc.fill       = GridBagConstraints.HORIZONTAL;
				gbc.anchor     = GridBagConstraints.NORTH;
				gbc.gridheight = 1;
				gbc.gridwidth  = 1;
				gbc.weightx    = 1.0;
				gbc.weighty    = 0.0;
				gbc.gridx      = 1;

				gbc.gridy      = 1;
				this.getContentPane().add(ec.getToolBarMain(includeToolBar), gbc);

				gbc.gridy      = 2;
				this.getContentPane().add(ec.getToolBarFormat(includeToolBar), gbc);

				gbc.gridy      = 3;
				this.getContentPane().add(ec.getToolBarStyles(includeToolBar), gbc);

				gbc.anchor     = GridBagConstraints.SOUTH;
				gbc.fill       = GridBagConstraints.BOTH;
				gbc.weighty    = 1.0;
				gbc.gridy      = 4;
				this.getContentPane().add(ec, gbc);
			}
			else
			{
				this.getContentPane().setLayout(new BorderLayout());
				this.getContentPane().add(ec, BorderLayout.CENTER);
				this.getContentPane().add(ec.getToolBar(includeToolBar), BorderLayout.NORTH);
			}
		}
		else
		{
			this.getContentPane().setLayout(new BorderLayout());
			this.getContentPane().add(ec, BorderLayout.CENTER);
		}

		this.setJMenuBar(ec.getMenuBar());

		this.pack();
    this.setTitle("Inhalt f\u00FCr E-Mail verfassen ...");
		ec.setVisible(true);

    this.setVisible(true);
  }

  public String getDocument()
  {
    return ec.getDocumentText();
  }
}
